package com.cspg.ssss.controller;

import com.cspg.ssss.domain.SecurityRiskLogEntity;
import com.cspg.ssss.service.SecurityRiskService;
import com.cspg.ssss.vo.ResultVo;
import com.cspg.ssss.vo.ResultVoUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 安风体系评级接口
 *
 * @author ybq
 * @since 2021-08-13
 */
@RestController
@RequestMapping("/securityRisk")
public class SecurityRiskController {

    @Autowired
    private SecurityRiskService riskService;

    /**
     *  id
     *  dwmc 单位名称
     *  gradeDiamond 钻石评级
     *  gradeStar 星星评级
     *  hangtag 挂牌
     *  warring 警示
     *  evaluate 评价
     */
    @GetMapping("/selectList")
    public ResultVo selectList() {
        return ResultVoUtil.success("查询成功", riskService.selectList(), "400");
    }

    /**
     *  gradeDiamond 钻石评级
     *  gradeStar 星星评级
     *  gradeReason 评级调整原因
     *  hangtag 挂牌
     *  hangtagReason 挂牌调整原因
     *  createBy 修改人
     *  createTime 修改时间
     */
    @GetMapping("/selectLogList")
    public ResultVo selectLogList(@RequestParam Map<String,Object> map) {
        return ResultVoUtil.success("查询成功", riskService.selectLogList(map), "400");
    }

    /**
     *  riskId
     *  type 类型：1=评级，2=挂牌
     *  gradeDiamond 钻石评级
     *  gradeStar 星星评级
     *  gradeReason 评级调整原因
     *  hangtag 挂牌
     *  hangtagReason 挂牌调整原因
     *  evaluate 评价
     *  createBy username
     */
    @PostMapping("/update")
    public ResultVo update(@RequestBody SecurityRiskLogEntity entity) {
        if (riskService.update(entity) > 0) {
            return ResultVoUtil.success("修改成功", null);
        } else {
            return ResultVoUtil.error("修改失败");
        }
    }

    @GetMapping("/insertList")
    public ResultVo insertList() {
        riskService.insertList();
        return ResultVoUtil.success("启动成功", null);
    }
}
